<?php
/*========================================= JooSam =========================================/
/																							/
/	Extention:		JooSam																	/
/	Created by:		ScriptPlanet.eu															/
/	Site:			http://www.scriptplanet.eu												/
/	Email:			support@scriptplanet.eu													/
/	Support:		http://www.scriptplanet.eu/support										/
/	Copyright:		2011 (c) ScriptPlanet.eu												/
/	License:		CC BY-NC-ND 3.0 ~ http://creativecommons.org/licenses/by-nc-nd/3.0/		/
/	File Version:	0001																	/
/																							/
/========================================== JooSam ========================================*/
// Joomla Security
defined('_JEXEC') or die;
JHTML::_('behavior.mootools');
jimport('joomla.application.component.helper');
if(JComponentHelper::isEnabled('com_joosam', true)):
	
	$partitle = $params->get('artTit');
	$parData = $params->get('artTxt');
	$parBg0 = $params->get('bgFirRow');
	$parBgHv0 = $params->get('bgFirRowHv');
	$parBg1 = $params->get('bgSecRow');
	$parBgHv1 = $params->get('bgSecRowHv');

	echo '<style type="text/css">';
	echo '
	.jsam_mod_queue .jsam_row .jsam_td_artist, .jsam_mod_queue .jsam_row .jsam_td_title{ width:50px; margin:0; padding:0 4px 0 0; text-align:left; color:#'.$partitle.'; }
	.jsam_mod_queue .jsam_row .jsam_td_artist_data, .jsam_mod_queue .jsam_row .jsam_td_title_data{ margin:0; padding:0; text-align:left; color:#'.$parData.'; }
	.jsam_mod_queue .jsam_table_bg0, .jsam_mod_queue .jsam_table_bg1{ width:100%; margin:0 0 5px 0; padding:0; }';
	if($parBg0 != 'FFFFFF' AND $parBg0 != ''){ echo '.jsam_mod_queue .jsam_table_bg0{ background:#'.$parBg0.'; margin:0; }'; }
	if($parBgHv0 != 'FFFFFF' AND $parBgHv0 != ''){ echo '.jsam_mod_queue .jsam_table_bg0:hover{ background:#'.$parBgHv0.'; }'; }
	if($parBg1 != 'FFFFFF' AND $parBg1 != ''){ echo '.jsam_mod_queue .jsam_table_bg1{ background:#'.$parBg1.'; margin:0; }'; }
	if($parBgHv1 != 'FFFFFF' AND $parBgHv1 != ''){ echo '.jsam_mod_queue .jsam_table_bg1:hover{ background:#'.$parBgHv1.'; }'; }
	echo '</style>';
	?>

	<div id="jsamQueue"></div>

	<script>
	/*********************************************************

		Name: jsam_mod_queue
		Version: 1.0
		Script: JavaScript
		Created by: ScriptPlanet.eu - Paules
		Site: http://www.scriptplanet.eu
		Description:	This script will use ajax to show
						information about the queue in SAM 
						Broadcaster.

	*********************************************************/
	// make ajax object
	function jsamQueuObject(){ var req; if(window.XMLHttpRequest){ req = new XMLHttpRequest(); } else if(window.ActiveXObject){ req = new ActiveXObject("Microsoft.XMLHTTP"); } else { alert("Your browser is to old to show this page."); } return req; }
	// var that load the objects
	var jsamQue = jsamQueuObject();
	// ajax load php for queue
	function jsamQueuSend(url){ jsamQue.open('post', url ,true); jsamQue.onreadystatechange = jsamQueuHandleResponse; jsamQue.send(null); }
	// on ready jsam queue
	function jsamQueuHandleResponse(){ if(jsamQue.readyState == 4 && jsamQue.status == 200){ var response = jsamQue.responseText; if(response){ document.getElementById("jsamQueue").innerHTML = response; } } }
	// set auto refresh for queue - 10sec 
	function jsamQueuRefresh(){ jsamQueuSend("<?php echo JRoute::_('index.php?option=com_joosam&view=modules&layout=queue&format=raw'); ?>"); setTimeout('jsamQueuRefresh()', 10000); }
	// window onload for queue
	window.onload = jsamQueuRefresh();
	</script>
<?php else: ?>
	<div id="jsamQueue">
		<div style="background:white; color:red; font-weight:bold; border-radius:10px; margin:1px; text-align:center; padding:0;">
			Component joosam is not installed.
		</div>
	</div><?php
endif;
?>